﻿@*@model SGIMail.Models.Contact*@
@*@model IEnumerable<SGIMail.Models.EventDetails>*@
@model SGIMail.Models.ContactViewModel

@{
    ViewBag.Title = "Details";
}
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
    google.load("visualization", "1", { packages: ["corechart"] });
    google.setOnLoadCallback(drawChart);

    function drawChart() {
        $.post('/Contacts/GetActivityData', {},
        function (data) {
            var tdata = new google.visualization.DataTable();
            tdata.addColumn('string', 'activity');
            tdata.addColumn('number', 'Frequency');


            for (var i = 0; i < data.length; i++) {
                tdata.addRow([data[i].activity, data[i].ContactCount]);
            }

            var options = {
                title: 'Absolute frequency of activitys for all events',

            };

            var chart = new google.visualization.BarChart(document.getElementById('chart_div2'));
            chart.draw(tdata, options);
        }
        );
    }
</script>

<script type="text/javascript">
    google.load("visualization", "1", { packages: ["corechart"] });
    google.setOnLoadCallback(drawChart);

    function drawChart() {
        $.post('/Contacts/GetThemeData', {},
        function (data) {
            var tdata = new google.visualization.DataTable();
            tdata.addColumn('string', 'activity');
            tdata.addColumn('number', 'Frequency');


            for (var i = 0; i < data.length; i++) {
                tdata.addRow([data[i].activity, data[i].ContactCount]);
            }

            var options = {
                title: 'Absolute frequency of themes for visited events',
                colors: ['green'],
                
            };

            var chart = new google.visualization.ColumnChart(document.getElementById('chart_div1'));
            chart.draw(tdata, options);
        }
        );
    }
</script>

<h2>Details</h2>

<div class="row">
    <div class="col-md-4">
        <h4>Contact</h4>
        <hr />
        <dl class="dl-horizontal">
            <dt>
                @Html.DisplayNameFor(model => model.Contact.Name)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.Contact.Name)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.Contact.Email)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.Contact.Email)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.Contact.Phone)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.Contact.Phone)
            </dd>
            <dt>
                @Html.DisplayNameFor(model=>model.Contact.Company.CompanyName)
            </dt>
            <dd>
                @Html.DisplayFor(model=> model.Contact.Company.CompanyName)
            </dd>
            <dt>
                Registered/Mailed
            </dt>
            <dd>
                @Html.DisplayFor(model=> model.Participation)
            </dd>
        </dl>
    </div>



        
        
    </div>
<div class="row">
    <div class="col-md-6"> <div id="chart_div1" style="width: 570px; height: 300px;"></div></div>
    <div class="col-md-6"> <div id="chart_div2" style="width: 570px; height: 300px;"></div></div>

</div>


<p>
    @*@Html.ActionLink("Edit", "Edit", new { id = Model.ContactId }) |
        @Html.ActionLink("Back to List", "Index")*@
</p>

<table class="table">
    @*<tr>
        <th>
            @Html.DisplayNameFor(model => model.Event.Name)
        </th>
        <th>
            @Html.DisplayName("Last activity")
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Event.Theme)
        </th>

        <th>
            <label>Category</label>
        </th>
    </tr>*@

    <tr>
        <th>
            @Html.DisplayName("Event")
        </th>
        <th>
            @Html.DisplayName("Last activity")
        </th>
        <th>
            @Html.DisplayName("Theme")
        </th>

        <th>
            <label>Category</label>
        </th>
    </tr>

    @foreach (var item in Model.EventDetails)
    {
        <tr>
            <td>
                @Html.ActionLink(item.Event.Name, "Details", "Event", new { id = item.EventId }, null)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Date)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Event.Theme)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Category)
            </td>
        </tr>
    }
</table>